#ifndef __BASE_STRING_H__
#define __BASE_STRING_H__

#include "typedef.h"
#include "array.h"

namespace base {
  class string;

  class cstring {
    public:
      static const uint npos;
      static const uint csize;
    public:
      cstring(cchar *src, uint size = csize);
      virtual ~cstring();
    public:
      bool empty() const;
      uint size() const;
      cchar* data() const;
      string string() const;
      char at(uint pos) const;

      bool equal(cchar *str, uint size = csize) const;
      bool start_with(cchar *str, uint size = csize) const;
      bool end_with(cchar *str, uint size = csize) const;

      int compare(cchar *str, uint size = csize) const;
      int compare_nocase(cchar *str, uint size = csize) const;

      uint find(uint pos, const cstring &str);
      uint rfind(uint pos, const cstring &str);
      uint find(uint pos, cchar *str, uint size = csize) const;
      uint rfind(uint pos, cchar *str, uint size = csize) const;

      cstring left(uint size) const;
      cstring right(uint size) const;
      cstring sub(uint pos, uint size) const;

      array<cstring> split(cchar *str, uint size = csize) const;
    protected:
      cchar *data_;
      uint size_;
  };

  class string : public cstring {
    public:
      string();
      string(cchar *src, uint size = csize);
      virtual ~string();
  };
} // end namespace base

#endif // end __BASE_STRING_H__